package fr.utbm.to52.android_bibtex.model.spec;

import java.util.HashMap;
import java.util.Map;

public enum Month {

	JANUARY {
		@Override
		public String shortName() { return "jan"; }
	},
	FEBRUARY {
		@Override
		public String shortName() { return "feb"; }
	},
	MARCH {
		@Override
		public String shortName() { return "mar"; }
	},
	APRIL {
		@Override
		public String shortName() { return "apr"; }
	},
	MAY {
		@Override
		public String shortName() { return "may"; }
	},
	JUNE {
		@Override
		public String shortName() { return "jun"; }
	},
	JULY {
		@Override
		public String shortName() { return "jul"; }
	},
	AUGUST {
		@Override
		public String shortName() { return "aug"; }
	},
	SEPTEMBER {
		@Override
		public String shortName() { return "sep"; }
	},
	OCTOBER {
		@Override
		public String shortName() { return "oct"; }
	},
	NOVEMBER {
		@Override
		public String shortName() { return "nov"; }
	},
	DECEMBER {
		@Override
		public String shortName() { return "dec"; }
	};

	public static final Month[] values = values();

	public static final Map<String, Month> mapByShortName = new HashMap<String, Month>();
	static {
		for (Month m : values) {
			mapByShortName.put(m.shortName(), m);
		}
	}

	public abstract String shortName();

	public static Month fromShortName(String shortName) {
		return mapByShortName.get(shortName.toLowerCase());
	}

	public int number() {
		return 1 + ordinal();
	}

	public static Month fromNumber(int number) {
		return values[number - 1];
	}
}
